home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectSound / EffectsBuffers / frmFX.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  22.5 KB  |  620 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  3. Begin VB.Form frmEffects 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Audio Effects using DirectSound Buffers"
  6.    ClientHeight    =   5790
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   4770
  10.    Icon            =   "frmFX.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    ScaleHeight     =   5790
  14.    ScaleWidth      =   4770
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin VB.Timer tmrUpdate 
  17.       Interval        =   50
  18.       Left            =   5760
  19.       Top             =   900
  20.    End
  21.    Begin VB.CheckBox chkLoop 
  22.       Caption         =   "Loop Sound"
  23.       Height          =   315
  24.       Left            =   840
  25.       TabIndex        =   16
  26.       Top             =   5340
  27.       Width           =   1455
  28.    End
  29.    Begin VB.CommandButton cmdStop 
  30.       Caption         =   "&Stop"
  31.       Height          =   375
  32.       Left            =   3600
  33.       TabIndex        =   14
  34.       Top             =   5340
  35.       Width           =   1095
  36.    End
  37.    Begin VB.CommandButton cmdPlay 
  38.       Caption         =   "&Play"
  39.       Height          =   375
  40.       Left            =   2400
  41.       TabIndex        =   13
  42.       Top             =   5340
  43.       Width           =   1095
  44.    End
  45.    Begin VB.Frame fraEffects 
  46.       Caption         =   "Effects Information"
  47.       Height          =   3675
  48.       Left            =   120
  49.       TabIndex        =   2
  50.       Top             =   1560
  51.       Width           =   4515
  52.       Begin VB.CommandButton cmdModify 
  53.          Caption         =   "Modify Selected Effects"
  54.          Enabled         =   0   'False
  55.          Height          =   315
  56.          Left            =   120
  57.          TabIndex        =   17
  58.          Top             =   3240
  59.          Width           =   2235
  60.       End
  61.       Begin VB.TextBox txtFile 
  62.          Height          =   285
  63.          Left            =   120
  64.          Locked          =   -1  'True
  65.          TabIndex        =   9
  66.          Text            =   "No file loaded..."
  67.          Top             =   480
  68.          Width           =   3915
  69.       End
  70.       Begin VB.CommandButton cmdBrowse 
  71.          Caption         =   "..."
  72.          Height          =   285
  73.          Left            =   4020
  74.          TabIndex        =   8
  75.          ToolTipText     =   "Open a new audio file..."
  76.          Top             =   480
  77.          Width           =   315
  78.       End
  79.       Begin VB.ListBox lstAvail 
  80.          Height          =   840
  81.          ItemData        =   "frmFX.frx":0442
  82.          Left            =   120
  83.          List            =   "frmFX.frx":045E
  84.          TabIndex        =   7
  85.          Top             =   1080
  86.          Width           =   4275
  87.       End
  88.       Begin VB.ListBox lstUse 
  89.          Height          =   840
  90.          Left            =   120
  91.          TabIndex        =   6
  92.          Top             =   2280
  93.          Width           =   4275
  94.       End
  95.       Begin VB.CommandButton cmdAdd 
  96.          Height          =   285
  97.          Left            =   2040
  98.          MaskColor       =   &H000000FF&
  99.          Picture         =   "frmFX.frx":04AF
  100.          Style           =   1  'Graphical
  101.          TabIndex        =   5
  102.          Top             =   1980
  103.          UseMaskColor    =   -1  'True
  104.          Width           =   315
  105.       End
  106.       Begin VB.CommandButton cmdRemove 
  107.          Height          =   285
  108.          Left            =   2400
  109.          MaskColor       =   &H000000FF&
  110.          Picture         =   "frmFX.frx":09F1
  111.          Style           =   1  'Graphical
  112.          TabIndex        =   4
  113.          Top             =   1980
  114.          UseMaskColor    =   -1  'True
  115.          Width           =   315
  116.       End
  117.       Begin VB.CommandButton cmdApply 
  118.          Caption         =   "Apply Effects"
  119.          Height          =   315
  120.          Left            =   2460
  121.          TabIndex        =   3
  122.          Top             =   3240
  123.          Width           =   1875
  124.       End
  125.       Begin VB.Label lbl 
  126.          BackStyle       =   0  'Transparent
  127.          Caption         =   "Currently loaded sound file:"
  128.          Height          =   195
  129.          Index           =   0
  130.          Left            =   120
  131.          TabIndex        =   12
  132.          Top             =   240
  133.          Width           =   4515
  134.       End
  135.       Begin VB.Label lbl 
  136.          BackStyle       =   0  'Transparent
  137.          Caption         =   "Available Effects"
  138.          Height          =   195
  139.          Index           =   1
  140.          Left            =   120
  141.          TabIndex        =   11
  142.          Top             =   840
  143.          Width           =   1215
  144.       End
  145.       Begin VB.Label lbl 
  146.          BackStyle       =   0  'Transparent
  147.          Caption         =   "Effects in use"
  148.          Height          =   195
  149.          Index           =   2
  150.          Left            =   120
  151.          TabIndex        =   10
  152.          Top             =   2040
  153.          Width           =   1215
  154.       End
  155.    End
  156.    Begin MSComDlg.CommonDialog cdlOpen 
  157.       Left            =   300
  158.       Top             =   3720
  159.       _ExtentX        =   847
  160.       _ExtentY        =   847
  161.       _Version        =   393216
  162.    End
  163.    Begin VB.Label lbl 
  164.       BackStyle       =   0  'Transparent
  165.       Caption         =   $"frmFX.frx":0F33
  166.       Height          =   675
  167.       Index           =   5
  168.       Left            =   120
  169.       TabIndex        =   15
  170.       Top             =   840
  171.       Width           =   4575
  172.    End
  173.    Begin VB.Label lbl 
  174.       BackStyle       =   0  'Transparent
  175.       Caption         =   "Audio Effects using DirectSoundBuffers"
  176.       Height          =   255
  177.       Index           =   4
  178.       Left            =   660
  179.       TabIndex        =   1
  180.       Top             =   60
  181.       Width           =   3195
  182.    End
  183.    Begin VB.Label lbl 
  184.       BackStyle       =   0  'Transparent
  185.       Caption         =   "Copyright (C) 1999-2001 Microsoft Corporation, All Rights Reserved."
  186.       Height          =   435
  187.       Index           =   3
  188.       Left            =   660
  189.       TabIndex        =   0
  190.       Top             =   300
  191.       Width           =   3555
  192.    End
  193.    Begin VB.Image Image1 
  194.       Height          =   480
  195.       Left            =   120
  196.       Picture         =   "frmFX.frx":0FCA
  197.       Top             =   180
  198.       Width           =   480
  199.    End
  200.    Begin VB.Menu mnuPop 
  201.       Caption         =   "pop"
  202.       Visible         =   0   'False
  203.       Begin VB.Menu mnuRemove 
  204.          Caption         =   "Remove"
  205.       End
  206.       Begin VB.Menu mnuChange 
  207.          Caption         =   "Change Settings..."
  208.       End
  209.    End
  210. Attribute VB_Name = "frmEffects"
  211. Attribute VB_GlobalNameSpace = False
  212. Attribute VB_Creatable = False
  213. Attribute VB_PredeclaredId = True
  214. Attribute VB_Exposed = False
  215. Option Explicit
  216. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  217. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  218. '  File:       frmFX.frm
  219. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  220. 'API declare for windows folder
  221. Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
  222. Private Const mlMaxEffects As Long = 20
  223. 'Private declares for our DirectX objects
  224. Private dx As DirectX8
  225. Private ds As DirectSound8
  226. Private dsb As DirectSoundSecondaryBuffer8
  227. Private mlEffectKey As Long
  228. Private Sub cmdAdd_Click()
  229.     If lstAvail.ListIndex = -1 Then 'Nothing is selected
  230.         MsgBox "Please select an available effect before attempting to add it.", vbOKOnly Or vbInformation, "Nothing selected."
  231.         Exit Sub
  232.     End If
  233.     If Not (dsb Is Nothing) Then
  234.         'Yup, now is there a sound already playing?
  235.         If (dsb.GetStatus And DSBSTATUS_PLAYING) = DSBSTATUS_PLAYING Then
  236.             MsgBox "Stop the currently playing sound before adding any effects.", vbOKOnly Or vbInformation, "Sound is playing"
  237.             Exit Sub
  238.         End If
  239.     End If
  240.     If lstUse.ListCount >= mlMaxEffects Then
  241.         MsgBox "You cannot add more than " & CStr(mlMaxEffects) & " effects in this sample.", vbOKOnly Or vbInformation, "No more effects."
  242.         Exit Sub
  243.     End If
  244.     'Add this item to our list of effects
  245.     lstUse.AddItem lstAvail.List(lstAvail.ListIndex) & " (Unallocated)"
  246.     RemoveAllForms
  247. End Sub
  248. Private Sub cmdApply_Click()
  249.     ApplySettings
  250. End Sub
  251. Private Sub cmdBrowse_Click()
  252.     Static sCurDir As String
  253.     Dim desc As DSBUFFERDESC
  254.     'We want to open a file now
  255.     cdlOpen.flags = cdlOFNHideReadOnly Or cdlOFNFileMustExist
  256.     cdlOpen.Filter = "Wave Files (*.wav)|*.wav"
  257.     cdlOpen.FileName = vbNullString
  258.     If sCurDir = vbNullString Then
  259.         'Set the init folder to \windows\media if it exists.  If not, set it to the \windows folder
  260.         Dim sWindir As String
  261.         sWindir = Space$(255)
  262.         If GetWindowsDirectory(sWindir, 255) = 0 Then
  263.             'We couldn't get the windows folder for some reason, use the c:\
  264.             cdlOpen.InitDir = "C:\"
  265.         Else
  266.             Dim sMedia As String
  267.             sWindir = Left$(sWindir, InStr(sWindir, Chr$(0)) - 1)
  268.             If Right$(sWindir, 1) = "\" Then
  269.                 sMedia = sWindir & "Media"
  270.             Else
  271.                 sMedia = sWindir & "\Media"
  272.             End If
  273.             'We are trying to find the windows\media directory.  If it
  274.             'doesn't exist, then use the windows folder as a default
  275.             If Dir$(sMedia, vbDirectory) <> vbNullString Then
  276.                 cdlOpen.InitDir = sMedia
  277.             Else
  278.                 cdlOpen.InitDir = sWindir
  279.             End If
  280.         End If
  281.     Else
  282.         'No need to move folders.  Stay where they picked the last file
  283.         cdlOpen.InitDir = sCurDir
  284.     End If
  285.     On Local Error GoTo ClickedCancel
  286.     cdlOpen.CancelError = True
  287.     cdlOpen.ShowOpen   ' Display the Open dialog box
  288.     'Save the current information
  289.     sCurDir = GetFolder(cdlOpen.FileName)
  290.             
  291.     On Local Error GoTo NoLoadSegment
  292.     'Before we load the buffer stop one if it's playing
  293.     If Not (dsb Is Nothing) Then If dsb.GetStatus = DSBSTATUS_PLAYING Then dsb.Stop
  294.     'We need to set the CTRLFX flag so we can control the effects on this object
  295.     desc.lFlags = DSBCAPS_CTRLFX
  296.     'Now let's load the segment
  297.     RemoveAllForms
  298.     Set dsb = ds.CreateSoundBufferFromFile(cdlOpen.FileName, desc)
  299.     mlEffectKey = 0
  300.     txtFile.Text = cdlOpen.FileName
  301.     Exit Sub
  302. NoLoadSegment:
  303.     If Err.Number = DSERR_BUFFERTOOSMALL Then 'This buffer isn't big enough to control effects on
  304.         MsgBox "This file isn't long enough to control effects.  Please choose a longer audio file.", vbOKOnly Or vbCritical, "Couldn't load"
  305.     Else 'Some other error
  306.         MsgBox "Couldn't load this file", vbOKOnly Or vbCritical, "Couldn't load"
  307.     End If
  308. ClickedCancel:
  309. End Sub
  310. Private Sub cmdModify_Click()
  311.     ChangeSettings
  312. End Sub
  313. Private Sub cmdPlay_Click()
  314.     If dsb Is Nothing Then
  315.         MsgBox "You must first load a wave file into a sound buffer before you can play it.", vbOKOnly Or vbInformation, "No buffer"
  316.         Exit Sub
  317.     End If
  318.     'We need to pre-roll any effects parameter changes that occurred since the last
  319.     'call to an API that does pre-rolling (ie, Stop or SetCurrentPosition)
  320.     dsb.SetCurrentPosition 0
  321.     dsb.Play chkLoop.Value
  322.     EnablePlayUI False
  323. End Sub
  324. Private Sub cmdRemove_Click()
  325.     Dim lLastIndex As Long
  326.     If lstUse.ListIndex = -1 Then 'Nothing is selected
  327.         MsgBox "Please select an effect that's being used before attempting to remove it.", vbOKOnly Or vbInformation, "Nothing selected."
  328.         Exit Sub
  329.     End If
  330.     If Not (dsb Is Nothing) Then
  331.         'Yup, now is there a sound already playing?
  332.         If (dsb.GetStatus And DSBSTATUS_PLAYING) = DSBSTATUS_PLAYING Then
  333.             MsgBox "Stop the currently playing sound before removing any effects.", vbOKOnly Or vbInformation, "Sound is playing"
  334.             Exit Sub
  335.         End If
  336.     End If
  337.     lLastIndex = lstUse.ListIndex
  338.     'Add this item to our list of effects
  339.     lstUse.RemoveItem lstUse.ListIndex
  340.     If (lstUse.ListCount > 0) Then
  341.         If lstUse.ListCount > lLastIndex Then
  342.             lstUse.ListIndex = lLastIndex
  343.         Else
  344.             lstUse.ListIndex = 0
  345.         End If
  346.     End If
  347.     'Enable the menus
  348.     If lstUse.ListCount < 1 Or lstUse.ListIndex < 0 Then
  349.         EnableMenus False
  350.     Else
  351.         EnableMenus True
  352.     End If
  353.     mlEffectKey = 0
  354.     RemoveAllForms
  355. End Sub
  356. Private Sub cmdStop_Click()
  357.     If dsb Is Nothing Then
  358.         MsgBox "You must first load a wave file into a sound buffer before you can stop it.", vbOKOnly Or vbInformation, "No buffer"
  359.         Exit Sub
  360.     End If
  361.     dsb.Stop
  362.     'Stop doesn't reset the current position
  363.     dsb.SetCurrentPosition 0
  364.     EnablePlayUI True
  365. End Sub
  366. Private Sub Form_Load()
  367.     EnablePlayUI True
  368.     InitDSound
  369. End Sub
  370. Private Sub Form_Unload(Cancel As Integer)
  371.     RemoveAllForms
  372.     CleanupDSound
  373. End Sub
  374. Private Sub InitDSound()
  375.     On Error GoTo FailedInit
  376.     Set dx = New DirectX8
  377.     'Create our default DirectSound object
  378.     Set ds = dx.DirectSoundCreate(vbNullString)
  379.     ds.SetCooperativeLevel Me.hWnd, DSSCL_NORMAL
  380.     Exit Sub
  381. FailedInit:
  382.     MsgBox "Could not initialize DirectSound." & vbCrLf & "This sample will exit.", vbOKOnly Or vbInformation, "Exiting..."
  383.     Unload Me
  384. End Sub
  385. Private Sub CleanupDSound()
  386.     'Let's clean up now
  387.     If Not dsb Is Nothing Then
  388.         'If we are playing our file, stop it
  389.         If dsb.GetStatus = DSBSTATUS_PLAYING Then dsb.Stop
  390.         'Destroy our objects
  391.         Set dsb = Nothing
  392.     End If
  393.     Set ds = Nothing
  394.     Set dx = Nothing
  395. End Sub
  396. Private Function GetFolder(ByVal sFile As String) As String
  397.     Dim lCount As Long
  398.     For lCount = Len(sFile) To 1 Step -1
  399.         If Mid$(sFile, lCount, 1) = "\" Then
  400.             GetFolder = Left$(sFile, lCount)
  401.             Exit Function
  402.         End If
  403.     Next
  404.     GetFolder = vbNullString
  405. End Function
  406. Private Sub lstAvail_DblClick()
  407.     'Double clicking should be the same as clicking the 'Add' button
  408.     cmdAdd_Click
  409. End Sub
  410. Private Sub lstUse_Click()
  411.     'Enable the menu
  412.     If lstUse.ListCount < 1 Or lstUse.ListIndex < 0 Then
  413.         EnableMenus False
  414.     Else
  415.         EnableMenus True
  416.     End If
  417. End Sub
  418. Private Sub lstUse_DblClick()
  419.     'Double clicking should be the same as clicking the 'Remove' button
  420.     cmdRemove_Click
  421. End Sub
  422. Private Sub lstUse_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  423.     If Button = vbRightButton Then
  424.         'Show the popup menu
  425.         If lstUse.ListCount < 1 Or lstUse.ListIndex < 0 Then
  426.             EnableMenus False
  427.         Else
  428.             EnableMenus True
  429.         End If
  430.         PopupMenu mnuPop, , X + lstUse.Left, Y + lstUse.Top + fraEffects.Top, mnuRemove
  431.     End If
  432. End Sub
  433. Private Sub EnableMenus(ByVal fEnable As Boolean)
  434.     mnuChange.Enabled = fEnable
  435.     mnuRemove.Enabled = fEnable
  436.     cmdModify.Enabled = fEnable
  437. End Sub
  438. Private Sub mnuChange_Click()
  439.     ChangeSettings
  440. End Sub
  441. Private Sub mnuRemove_Click()
  442.     cmdRemove_Click
  443. End Sub
  444. Private Sub ChangeSettings()
  445.     Dim fGargle As frmGargle, fCompressor As frmCompressor
  446.     Dim fEcho As frmEcho, fDistortion As frmDistortion
  447.     Dim fChorus As frmChorus, fFlanger As frmFlanger
  448.     Dim fParam As frmParamEQ, fWave As frmWaves
  449.     Dim lIndex As Long, lCount As Long
  450.     On Error GoTo LeaveSub
  451.     'First we need to force the effects to be applied
  452.     If Not ApplySettings(True) Then Exit Sub
  453.     'No need to continue if the sound is playing or there is no sound buffer
  454.     If dsb Is Nothing Then Exit Sub
  455.     'Now we need to get the index of this effect
  456.     lIndex = -1
  457.     For lCount = 0 To lstUse.ListIndex
  458.         If LCase(lstUse.List(lstUse.ListIndex)) = LCase(lstUse.List(lCount)) Then lIndex = lIndex + 1
  459.     Next
  460.     'Now show the correct screen based on the info
  461.     Select Case Left$(LCase(lstUse.List(lstUse.ListIndex)), InStr(lstUse.List(lstUse.ListIndex), " ") - 1)
  462.     Case "distortion"
  463.         Set fDistortion = New frmDistortion
  464.         fDistortion.SetBuffer dsb, lIndex
  465.         fDistortion.Show vbModeless, Me
  466.     Case "echo"
  467.         Set fEcho = New frmEcho
  468.         fEcho.SetBuffer dsb, lIndex
  469.         fEcho.Show vbModeless, Me
  470.     Case "chorus"
  471.         Set fChorus = New frmChorus
  472.         fChorus.SetBuffer dsb, lIndex
  473.         fChorus.Show vbModeless, Me
  474.     Case "flanger"
  475.         Set fFlanger = New frmFlanger
  476.         fFlanger.SetBuffer dsb, lIndex
  477.         fFlanger.Show vbModeless, Me
  478.     Case "compressor"
  479.         Set fCompressor = New frmCompressor
  480.         fCompressor.SetBuffer dsb, lIndex
  481.         fCompressor.Show vbModeless, Me
  482.     Case "gargle"
  483.         Set fGargle = New frmGargle
  484.         fGargle.SetBuffer dsb, lIndex
  485.         fGargle.Show vbModeless, Me
  486.     Case "parameq"
  487.         Set fParam = New frmParamEQ
  488.         fParam.SetBuffer dsb, lIndex
  489.         fParam.Show vbModeless, Me
  490.     Case "wavesreverb"
  491.         Set fWave = New frmWaves
  492.         fWave.SetBuffer dsb, lIndex
  493.         fWave.Show vbModeless, Me
  494.     End Select
  495. LeaveSub:
  496. End Sub
  497. Private Sub EnablePlayUI(ByVal fEnable As Boolean)
  498.     On Error Resume Next
  499.     If fEnable Then
  500.         chkLoop.Enabled = True
  501.         cmdPlay.Enabled = True
  502.         cmdStop.Enabled = False
  503.         cmdBrowse.Enabled = True
  504.         cmdPlay.SetFocus
  505.     Else
  506.         chkLoop.Enabled = False
  507.         cmdPlay.Enabled = False
  508.         cmdStop.Enabled = True
  509.         cmdBrowse.Enabled = False
  510.         cmdStop.SetFocus
  511.     End If
  512. End Sub
  513. Private Sub tmrUpdate_Timer()
  514.     If Not (dsb Is Nothing) Then
  515.         If (dsb.GetStatus And DSBSTATUS_PLAYING) <> DSBSTATUS_PLAYING Then
  516.             If cmdPlay.Enabled = False Then
  517.                 EnablePlayUI True
  518.             End If
  519.         End If
  520.     End If
  521. End Sub
  522. Private Function ApplySettings(Optional ByVal fIgnoreSoundPlaying As Boolean = False) As Boolean
  523.     On Local Error GoTo NoFX
  524.     Dim DSEffects() As DSEFFECTDESC
  525.     Dim lResults() As Long
  526.     Dim lCount As Long
  527.     Dim lTempEffect As Long
  528.     'Do we have a sound buffer
  529.     If dsb Is Nothing Then
  530.         MsgBox "You must first load a wave file into a sound buffer before you can apply effects to it.", vbOKOnly Or vbInformation, "No buffer"
  531.         Exit Function
  532.     End If
  533.     If Not fIgnoreSoundPlaying Then
  534.         'Yup, now is there a sound already playing?
  535.         If (dsb.GetStatus And DSBSTATUS_PLAYING) = DSBSTATUS_PLAYING Then
  536.             MsgBox "Stop the currently playing sound before adding effects.", vbOKOnly Or vbInformation, "Sound is playing"
  537.             Exit Function
  538.         End If
  539.     End If
  540.     'Yes we do, do we have effects selected?
  541.     If lstUse.ListCount = 0 Then
  542.         If MsgBox("Do you want to turn off effects for this buffer?", vbYesNo Or vbQuestion, "No effects") = vbYes Then
  543.             dsb.SetFX 0, DSEffects, lResults
  544.             Exit Function
  545.         Else
  546.             MsgBox "You must first select some effects to use.", vbOKOnly Or vbInformation, "No effects"
  547.             Exit Function
  548.         End If
  549.     End If
  550.     'Ok, let's apply our effects info here
  551.     'First get an array of effects structs the right size
  552.     ReDim DSEffects(lstUse.ListCount - 1)
  553.     ReDim lResults(lstUse.ListCount - 1)
  554.     'Now we don't want to apply the effects if they've already been applied.  So,
  555.     'through our list, and create a 'unique' number to describe this set of effects
  556.     'and only apply them if the number is different form our stored one.
  557.     For lCount = 0 To lstUse.ListCount - 1
  558.         Select Case Left$(LCase(lstUse.List(lCount)), InStr(lstUse.List(lCount), " ") - 1)
  559.         Case "distortion"
  560.             lTempEffect = lTempEffect + (lCount + &H10)
  561.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_DISTORTION
  562.         Case "echo"
  563.             lTempEffect = lTempEffect + (lCount + &H20)
  564.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_ECHO
  565.         Case "chorus"
  566.             lTempEffect = lTempEffect + (lCount + &H40)
  567.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_CHORUS
  568.         Case "flanger"
  569.             lTempEffect = lTempEffect + (lCount + &H80)
  570.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_FLANGER
  571.         Case "compressor"
  572.             lTempEffect = lTempEffect + (lCount + &H100)
  573.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_COMPRESSOR
  574.         Case "gargle"
  575.             lTempEffect = lTempEffect + (lCount + &H200)
  576.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_GARGLE
  577.         Case "parameq"
  578.             lTempEffect = lTempEffect + (lCount + &H400)
  579.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_PARAMEQ
  580.         Case "wavesreverb"
  581.             lTempEffect = lTempEffect + (lCount + &H800)
  582.             DSEffects(lCount).guidDSFXClass = DSFX_STANDARD_WAVES_REVERB
  583.         End Select
  584.     Next
  585.     If mlEffectKey <> lTempEffect Then 'They don't match, set the fx.
  586.         dsb.SetFX lstUse.ListCount, DSEffects, lResults
  587.         Dim sNewItem As String
  588.         For lCount = 0 To lstUse.ListCount - 1
  589.             sNewItem = Left$(lstUse.List(lCount), InStr(lstUse.List(lCount), " ") - 1)
  590.             Select Case lResults(lCount)
  591.             Case DSFXR_FAILED
  592.                 lstUse.List(lCount) = sNewItem & " - Failed"
  593.             Case DSFXR_LOCHARDWARE
  594.                 lstUse.List(lCount) = sNewItem & " - Hardware"
  595.             Case DSFXR_LOCSOFTWARE
  596.                 lstUse.List(lCount) = sNewItem & " - Software"
  597.             Case DSFXR_UNALLOCATED
  598.                 lstUse.List(lCount) = sNewItem & " - Unallocated"
  599.             Case DSFXR_UNKNOWN
  600.                 lstUse.List(lCount) = sNewItem & " - Unknown"
  601.             Case DSFXR_PRESENT
  602.                 lstUse.List(lCount) = sNewItem & " - Present"
  603.             End Select
  604.         Next
  605.     End If
  606.     mlEffectKey = lTempEffect
  607.     ApplySettings = True
  608.     Exit Function
  609. NoFX:
  610.     MsgBox "This set of effects could not be set on this audio file.", vbOKOnly Or vbInformation, "Cannot set"
  611.     ApplySettings = False
  612. End Function
  613. Private Sub RemoveAllForms()
  614.     'Get rid of all forms
  615.     Dim f As Form
  616.     For Each f In Forms
  617.         If Not (f Is Me) Then Unload f
  618.     Next
  619. End Sub
  620.